<?php
session_start();
include dirname(__FILE__).'/s_user-manage/function.php';
?>
<html>
	<head>
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="stylesheet" type="text/css" href="css/cmxform.css">
	<?php include dirname(dirname(__FILE__)).'/include/common-header.php';?>
	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript" src="../js/jquery.validate.js"></script>
		<title>绿艺网站系统</title>
	<script type="text/javascript">
	$(document).ready(function(){
		<?php
				if(isset($_POST['login_username'])&&isset($_POST['login_password'])) {
					echo '$("#login_username").val("'.$_POST['login_username'].'");';
					echo '$("#login_password").val("'.$_POST['login_password'].'");';
					echo '$("#myModal-login").modal(show);';
				}
		?>
	$(".nav-click").click(function() {
		$(".nav li").removeClass("active");
		$(this).parent().addClass("active");
		var goto = $.trim($(this).attr("goto"));
		if(goto!='') {
			$("#main-content").attr("src",goto);
		}
	});

	$("#s_user-center").click(function(){
		$(".nav li").removeClass("active");
		var goto = $.trim($(this).attr("goto"));
		if(goto!='') {
			$("#main-content").attr("src",goto);
		}
		
		
		});

	$("#username").blur(function(){
	var _userName=$.trim($(this).val());
	if(_userName==null||_userName=='')return;
	$.ajax({
		dataType:"text",
		url:'s_user-manage/ajax/is-username-exist.php',
		data:{username:_userName},
		success:function(data) {
			if(data=='yes') {
				$("#username").parent().parent().addClass("has-error");
				$("#help-block").html("此用户已存在").fadeIn();
				$("#submit-btn").attr("disabled","disabled");
			} else {
				$("#username").parent().parent().removeClass("has-error")
				$("#help-block").hide();
				$("#submit-btn").removeAttr("disabled");
			}
		},
	});
	});

	// validate signup form on keyup and submit
	$("#register-form").validate({
		rules: {
			username: {
				required: true,
				minlength: 4
			},
			password: {
				required: true,
				minlength: 6
			},
			confirm_password: {
				required: true,
				minlength: 6,
				equalTo: "#password"
			},
			student_id: {
				required: true
			},
			department:{
			    required:true
			},
			grade:{
			   required:true
			},
			user_real_name:{
			    required:true
			},
			phone:{
				required:true
			},
			
		},
		messages: {
		
			username: {
				required: "请填写用户账号",
				minlength: "用户账号长度至少为4"
			},
			password: {
				required: "请填写用户密码",
				minlength: "用户密码长度至少为6"
			},
			confirm_password: {
				required: "请确认密码",
				minlength: "用户密码长度至少为6",
				equalTo: "两次密码不一致"
			},
			student_id: {
			 required:"请填写学号"
			 },
			 department:{
			  
			  required:"请填写院系"
			 
			 },
			 grade:{
			   required:"请填写年级"
			 },
			 
			 user_real_name:{
			     required:"请填写真实姓名"
			 },
			 phone:{
				 required:"请填写联系方式"
			 },
		}
	});
	$("#login-form").validate({
		rules: {
			login_username: {
				required: true
				
			},
			login_password: {
				required: true
			},
		
			
		},
		messages: {
		
			login_username: {
				required: "请填写用户账号"
			},
			login_password: {
				required: "请填写用户密码"
			},
		}
	});
	$(".unlogin").click(function(){
		$("#login-button").click();
		
	});
	
	});
	</script>
	</head>
	<body >
	<nav class=" navbar navbar-default navbar-fixed-top nav-show col-sm-10 container-fluid" role="navigation">
  <div class="container-fluid ">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class=" active"><a class="nav-click" href="javascript:void(0);" goto="announcement-manage/index.php">首页</a></li>
        <li><a class="nav-click" href="javascript:void(0);" goto="goods-show/index.php">经营范围</a></li>
        <?php 
        	if (isset($_SESSION['s_username'])) {		
				echo '<li><a class="nav-click" href="javascript:void(0);" goto="employ/index.php">人员招聘</a></li>
					<li class="dropdown">
          				<a href="#" class="dropdown-toggle" data-toggle="dropdown">书报管理 <span class="caret"></span></a>
         				 <ul class="dropdown-menu" role="menu">
           					 <li><a class="nav-click" href="javascript:void(0);" goto="books-manage/index.php">书刊经营</a></li>
           					 <li><a class="nav-click" href="javascript:void(0);" goto="exchange-books/index.php">以书换书</a></li>
							 <li><a class="nav-click" href="javascript:void(0);" goto="exchange-books/exchange.php">发布换书</a></li>
						</ul>
					</li>
       				<li ><a class="nav-click" href="javascript:void(0);" goto="place-apply/index.php">场地申请 </a></li>
       				<li><a class="nav-click" href="javascript:void(0);" goto="production-deliver/index.php">作品投递</a></li>
      				 <li><a class="nav-click" href="javascript:void(0);" goto="aid-apply/index.php">申请资助</a></li>';
        		
        	}else {
				echo '<li><a class="nav-click unlogin" href="javascript:void(0);" goto="">人员招聘</a></li>
					<li class="dropdown">
          				<a href="#" class="dropdown-toggle" data-toggle="dropdown">书报管理 <span class="caret"></span></a>
         				 <ul class="dropdown-menu" role="menu">
           					 <li><a class="nav-click unlogin" href="javascript:void(0);" >书刊经营</a></li>
           					 <li><a class="nav-click unlogin" href="javascript:void(0);" >以书换书</a></li>
							 <li><a class="nav-click unlogin" href="javascript:void(0);" >发布换书</a></li>
						</ul>
					</li>
       				<li ><a class="nav-click unlogin" href="javascript:void(0);" >场地申请 </a></li>
       				<li><a class="nav-click unlogin" href="javascript:void(0);" >作品投递</a></li>
      				 <li><a class="nav-click unlogin" href="javascript:void(0);" >申请资助</a></li>';
        		
        	}?>
        
       
      </ul>

      <ul class="nav navbar-nav navbar-right">
      	<?php 
      	
      	if (!isset($_SESSION['s_username'])) {
			echo ' <li><button id="login-button" class="btn btn-primary " data-toggle="modal" data-target="#myModal-login">登录</button></li>
        <li><button class="btn" data-toggle="modal" data-target="#myModal-register">注册</button> </li>';
      	}else {
			echo '<label class=" control-label">'.$_SESSION['s_username'].'</label>';
			echo '<a id="s_user-center" name="s_user-center" href="#" goto="s_user-manage/user-center.php" class=" btn btn-primary" role="button" >用户中心</a>
				<a href="s_user-manage/log-out.php" class="btn btn-primary" role="button" >退出</a>';
      	}
      	
      	?>
       
      </ul>
      
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<?php include dirname(__FILE__).'/s_user-manage/model-login.php';
	  include dirname(__FILE__).'/s_user-manage/model-register.php';?>
<div class="row" style="margin-top: 50px;">
</div>

	
<div class="container-fluid">
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-10 div-main-content">
<script type="text/javascript" language="javascript">
					function IFrameReSize() {
						var iframename = 'main-content';
						var pTar = document.getElementById(iframename);
						if (pTar) {
							if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
								pTar.height = pTar.contentDocument.body.offsetHeight;
							} //ie
							else if (pTar.Document && pTar.Document.body.scrollHeight) {
								pTar.height = pTar.Document.body.scrollHeight;
							}
							if(pTar.height<document.documentElement.clientHeight+100)pTar.height = document.documentElement.clientHeight+100;
						}
					}
				</script> 
				<iframe  id="main-content" name="main-content"  
				onLoad="IFrameReSize()"  allowTransparency="true" scrolling="no" width="100%" height="100%" src="announcement-manage/index.php" frameborder="0"   >
					
				</iframe>
</div>
<div class="col-sm-1"></div>
</div>
</div>
<?php include dirname(__FILE__)."/footer.php";?>
	</body>
</html>